﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Newtonsoft.Json;
using System.IO;
using Windows.Storage;
using System.Runtime.Serialization;

namespace CityDashboard
{
    class MainViewModel
    {


        CitydashboardServiceReference.Service1Client CitydashboardService;

        #region Version 1
        #region variable
        private int _sohs = 0;
        private int _sohsGQdunghan;
        private int _sohsGQtrehan;
        private int _sohsChuaGQdunghan;
        private int _sohsChuaGQtrehan;
        private int _sohsGQ;
        private int _sohsChuaGQ;

        private string _per_gqdh;
        private string _per_gqth;
        private string _per_cgqdh;
        private string _per_cgqth;

   

        private int _hosoTrinhUBND;
        private int _hosoChuaTrinhUBND;
        private int _hosoTrinhUBND_gq;
        private int _hosoTrinhUBND_cgq;
        private int _hosoTrinhKHDT;
        private int _hosoTrinhKHDT_gq;
        private int _hosoTrinhKHDT_cgq;

        private int _tongduan_dautu;
        private int _tongtheodoi;
        private int _tongtrehen;
        private int _tongdunghen;

        private float _dagq_phantram;
        private float _chuagq_phantram;

        private float _trinhUBdagq_phantram;
        private float _trinhUBchuagq_phantram;

        private float _trinhUB_phantram;
        private float _ChuatrinhUB_phantram;


        private string _duanHieuluc;
        private string _doanhnghiepHoatDong;

        private string _duanGiaithe;
        private string _duanCapmoi;

        private string _tongduanByDN;
        private string _tongduanByDT;

        private string _tongduanByDN_usd;
        private string _tongduanByDT_usd;

        private int _tongduanByDN_int;
        private int _tongduanByDT_int;

        private string _tonghepza;
        private string _tongSHTP;
        private string _tongOthers;

        private string _hosoTrinhUBDangGQTre;
        private string _hosoTrinhUB_Tre;
        private string _hosoChuaTrinhUB_Tre;


        public string hosoChuaTrinhUB_Tre
        {
            get
            {
                return _hosoChuaTrinhUB_Tre;
            }
            set
            {
                _hosoChuaTrinhUB_Tre = value;
            }
        }


        public string hosoTrinhUB_Tre
        {
            get
            {
                return _hosoTrinhUB_Tre;
            }
            set
            {
                _hosoTrinhUB_Tre = value;
            }
        }


        public string hosoTrinhUBDangGQTre
        {
            get
            {
                return _hosoTrinhUBDangGQTre;
            }
            set
            {
                _hosoTrinhUBDangGQTre = value;
            }
        }


        public string tongOthers
        {
            get
            {
                return _tongOthers;
            }
            set
            {
                _tongOthers = value;
            }
        }

       

        public string tongSHTP
        {
            get
            {
                return _tongSHTP;
            }
            set
            {
                _tongSHTP = value;
            }
        }


      

        public string tonghepza
        {
            get
            {
                return _tonghepza;
            }
            set
            {
                _tonghepza = value;
            }
        }

        public string tongduanByDT_usd
        {
            get
            {
                return _tongduanByDT_usd;
            }
            set
            {
                _tongduanByDT_usd = value;
            }
        }

        public string tongduanByDN_usd
        {
            get
            {
                return _tongduanByDN_usd;
            }
            set
            {
                _tongduanByDN_usd = value;
            }
        }

        public int tongduanByDT_int
        {
            get
            {
                return _tongduanByDT_int;
            }
            set
            {
                _tongduanByDT_int = value;
            }
        }



        public int tongduanByDN_int
        {
            get
            {
                return _tongduanByDN_int;
            }
            set
            {
                _tongduanByDN_int = value;
            }
        }

        public string tongduanByDT
        {
            get
            {
                return _tongduanByDT;
            }
            set
            {
                _tongduanByDT = value;
            }
        }


        public string tongduanByDN
        {
            get
            {
                return _tongduanByDN;
            }
            set
            {
                _tongduanByDN = value;
            }
        }



        public string duanCapmoi
        {
            get
            {
                return _duanCapmoi;
            }
            set
            {
                _duanCapmoi = value;
            }
        }

        public string duanGiaithe
        {
            get
            {
                return _duanGiaithe;
            }
            set
            {
                _duanGiaithe = value;
            }
        }


        public string doanhnghiepHoatDong
        {
            get
            {
                return _doanhnghiepHoatDong;
            }
            set
            {
                _doanhnghiepHoatDong = value;
            }
        }


     

        public string duanHieuluc
        {
            get
            {
                return _duanHieuluc;
            }
            set
            {
                _duanHieuluc = value;
            }
        }

        public float ChuatrinhUB_phantram
        {
            get
            {
                return _ChuatrinhUB_phantram;
            }
            set
            {
                _ChuatrinhUB_phantram = value;
            }
        }

        public float TrinhUB_phantram
        {
            get
            {
                return _trinhUB_phantram;
            }
            set
            {
                _trinhUB_phantram = value;
            }
        }


        public int HSChuaTrinhUBND
        {
            get
            {
                return _hosoChuaTrinhUBND;
            }
            set
            {
                _hosoChuaTrinhUBND = value;
            }
        }

        public float trinhUBchuagq_phantram
        {
            get
            {
                return _trinhUBchuagq_phantram;
            }
            set
            {
                _trinhUBchuagq_phantram = value;
            }
        }


        public float trinhUBdagq_phantram
        {
            get
            {
                return _trinhUBdagq_phantram;
            }
            set
            {
                _trinhUBdagq_phantram = value;
            }
        }


        public float chuagq_phantram
        {
            get
            {
                return _chuagq_phantram;
            }
            set
            {
                _chuagq_phantram = value;
            }
        }


        public float dagq_phantram
        {
            get
            {
                return _dagq_phantram;
            }
            set
            {
                _dagq_phantram = value;
            }
        }

        public int tongdunghen
        {
            get
            {
                return _tongdunghen;
            }
            set
            {
                _tongdunghen = value;
            }
        }
        public int tongtrehen
        {
            get
            {
                return _tongtrehen;
            }
            set
            {
                _tongtrehen = value;
            }
        }


        public int tongtheodoi
        {
            get
            {
                return _tongtheodoi;
            }
            set
            {
                _tongtheodoi = value;
            }
        }



        public int tongduan_dautu
        {
            get
            {
                return _tongduan_dautu;
            }
            set
            {
                _tongduan_dautu = value;
            }
        }



        public int TrinhUBND_cgq
        {
            get
            {
                return _hosoTrinhUBND_cgq;
            }
            set
            {
                _hosoTrinhUBND_cgq = value;
            }
        }

        public int TrinhUBND_gq
        {
            get
            {
                return _hosoTrinhUBND_gq;
            }
            set
            {
                _hosoTrinhUBND_gq = value;
            }
        }
        public int TrinhUBND
        {
            get
            {
                return _hosoTrinhUBND;
            }
            set
            {
                _hosoTrinhUBND = value;
            }
        }

        public int TrinhKHDT_cgq
        {
            get
            {
                return _hosoTrinhKHDT_cgq;
            }
            set
            {
                _hosoTrinhKHDT_cgq = value;
            }
        }

        public int TrinhKHDT_gq
        {
            get
            {
                return _hosoTrinhKHDT_gq;
            }
            set
            {
                _hosoTrinhKHDT_gq = value;
            }
        }
        public int TrinhKHDT
        {
            get
            {
                return _hosoTrinhKHDT;
            }
            set
            {
                _hosoTrinhKHDT = value;
            }
        }

       
        public string per_cgqth
        {
            get
            {
                return _per_cgqth;
            }
            set
            {
                _per_cgqth = value;
            }
        }

        public string per_cgqdh
        {
            get
            {
                return _per_cgqdh;
            }
            set
            {
                _per_cgqdh = value;
            }
        }

        public string per_gqth
        {
            get
            {
                return _per_gqth;
            }
            set
            {
                _per_gqth = value;
            }
        }
        public string per_gqdh
        {
            get
            {
                return _per_gqdh;
            }
            set
            {
                _per_gqdh = value;
            }
        }



        public int SohsChuaGQ
        {
            get
            {
                return _sohsChuaGQ;
            }
            set
            {
                _sohsChuaGQ = value;
            }
        }

        public int SohsGQ
        {
            get
            {
                return _sohsGQ;
            }
            set
            {
                _sohsGQ = value;
            }
        }
        public int SoHoso
        {
            get
            {
                return _sohs;
            }
            set
            {
                _sohs = value;
            }
        }

        public int SohsGQdunghan
        {
            get
            {
                return _sohsGQdunghan;
            }
            set
            {
                _sohsGQdunghan = value;
            }
        }

        public int SohsGQtrehan
        {
            get
            {
                return _sohsGQtrehan;
            }
            set
            {
                _sohsGQtrehan = value;
            }
        }

        public int SohsChuaGQdunghan
        {
            get
            {
                return _sohsChuaGQdunghan;
            }
            set
            {
                _sohsChuaGQdunghan = value;
            }
        }

        public int SohsChuaGQtrehan
        {
            get
            {
                return _sohsChuaGQtrehan;
            }
            set
            {
                _sohsChuaGQtrehan = value;
            }
        }

        #endregion
        #region view tong quat

        private readonly ObservableCollection<ViewTTTongQuatHPT> _ViewTTTongQuatHPT_obj = new ObservableCollection<ViewTTTongQuatHPT>();
        public ObservableCollection<ViewTTTongQuatHPT> ViewTTTongQuatHPT_obj
        {
            get
            {
                return _ViewTTTongQuatHPT_obj;
            }
        }

        public async void add_ViewTTTongQuatHPT()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewTTTongQuatHPTAsync();
            _ViewTTTongQuatHPT_obj.Clear();

            foreach (var Emp in EmpList)
            {
                _ViewTTTongQuatHPT_obj.Add(new ViewTTTongQuatHPT() { Id = Emp.Id, LoaiHs = Emp.loai_hs, Percent_soluong_dunghan = Emp.percent_soluong_dunghan, Percent_soluong_trehan = Emp.percent_soluong_trehan, Soluong_dunghan = Emp.soluong_dunghan, Soluong_trehan = Emp.soluong_trehan, Soluong_tt = Emp.soluong_tt });
            }

        }




        private readonly ObservableCollection<ObjectBase> _TrinhUB_gqdh = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> TrinhUB_gqdh
        {
            get
            {
                return _TrinhUB_gqdh;
            }
        }

        public async void add_TrinhUB_gqdh()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.DagqUBNDAsync();
            _TrinhUB_gqdh.Clear();

            foreach (var Emp in EmpList)
            {
                _TrinhUB_gqdh.Add(new ObjectBase() { Name = Emp.Name, Sl = Emp.Soluong, Flag = 1 });
            }

        }


        private readonly ObservableCollection<ObjectBase> _TrinhUB_gqth = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> TrinhUB_gqth
        {
            get
            {
                return _TrinhUB_gqth;
            }
        }

        public async void add_TrinhUB_gqth()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.ChuagqUBNDAsync();
            _TrinhUB_gqth.Clear();

            foreach (var Emp in EmpList)
            {
                _TrinhUB_gqth.Add(new ObjectBase() { Name = Emp.Name, Sl = Emp.Soluong, Flag = 2 });
            }

        }



        private readonly ObservableCollection<ObjectBase> _TrinhUB_cgqdh = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> TrinhUB_cgqdh
        {
            get
            {
                return _TrinhUB_cgqdh;
            }
        }

        public async void add_TrinhUB_cgqdh()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.HStrinhUBNDTPAsync();
            _TrinhUB_cgqdh.Clear();

            foreach (var Emp in EmpList)
            {
                _TrinhUB_cgqdh.Add(new ObjectBase() { Name = Emp.Name, Sl = Emp.Soluong, Flag = 1 });
            }

        }



        private readonly ObservableCollection<ObjectBase> _TrinhUB_cgqth = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> TrinhUB_cgqth
        {
            get
            {
                return _TrinhUB_cgqth;
            }
        }

        public async void add_TrinhUB_cgqth()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.HSChuatrinhUBNDTPAsync();
            _TrinhUB_cgqth.Clear();

            foreach (var Emp in EmpList)
            {
                _TrinhUB_cgqth.Add(new ObjectBase() { Name = Emp.Name, Sl = Emp.Soluong, Flag = 2});
            }

        }


        private readonly ObservableCollection<ObjectBase> _HsDaGiaiQuyet = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> HsDaGiaiQuyet
        {
            get
            {
                return _HsDaGiaiQuyet;
            }
        }

        public async void add_HsDaGiaiQuyet()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.HsDaGiaiQuyetAsync();
            _HsDaGiaiQuyet.Clear();

            foreach (var Emp in EmpList)
            {
                _HsDaGiaiQuyet.Add(new ObjectBase() { Name = Emp.Name, Sl = Emp.Soluong });
            }

        }

        private readonly ObservableCollection<ObjectBase> _HsDangGiaiQuyet = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> HsDangGiaiQuyet
        {
            get
            {
                return _HsDangGiaiQuyet;
            }
        }

        public async void add_HsDangGiaiQuyet()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.HsDangGiaiQuyetAsync();
            _HsDangGiaiQuyet.Clear();

            foreach (var Emp in EmpList)
            {
                _HsDangGiaiQuyet.Add(new ObjectBase() { Name = Emp.Name, Sl = Emp.Soluong });
            }

        }

        #endregion

        #region Ho so nhan theo du an dau tu
    

        private readonly ObservableCollection<ObjectBase> _duandautu_byloaiDN = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> duandautu_byloaiDN
        {
            get
            {
                return _duandautu_byloaiDN;
            }
        }

        public async void add_duandautubyloaiDN()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byloaiDN_HPTAsync();
            _duandautu_byloaiDN.Clear();

            foreach (var Emp in EmpList)
            {
                _duandautu_byloaiDN.Add(new ObjectBase() { Name = Emp.tenloaidn, Sl = Emp.SL });
            }

        }

        private readonly ObservableCollection<ObjectBase> _duandautu_byloaihinhDT = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> duandautu_byloaihinhDT
        {
            get
            {
                return _duandautu_byloaihinhDT;
            }
        }

        public async void add_duandautubyloaihinhDT()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byTenloaiHinhDT_HPTAsync();
            _duandautu_byloaihinhDT.Clear();

            foreach (var Emp in EmpList)
            {
                _duandautu_byloaihinhDT.Add(new ObjectBase() { Name = Emp.tenloaihinhDT, Sl = Emp.SL });
            }

        }

        private readonly ObservableCollection<ObjectBase> _duandautu_byloaihinhDT_USD = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> duandautu_byloaihinhDT_USD
        {
            get
            {
                return _duandautu_byloaihinhDT_USD;
            }
        }

        public async void add_duandautubyloaihinhDT_USD()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byTenloaiHinhDT_USD_HPTAsync();
            _duandautu_byloaihinhDT_USD.Clear();

            foreach (var Emp in EmpList)
            {
                _duandautu_byloaihinhDT_USD.Add(new ObjectBase() { Name = Emp.tenloaihinhDT, Sl = (int)Emp.SL });
            }

        }

        private readonly ObservableCollection<ObjectBase> _duandautu_byQuocTich_BC = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> duandautu_byQuocTich_BC
        {
            get
            {
                return _duandautu_byQuocTich_BC;
            }
        }

        public async void add_duandautubyQuocTich_BC()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byTenQuocTich_BC_HPTAsync();
            _duandautu_byQuocTich_BC.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                if (count > 10) break;
                _duandautu_byQuocTich_BC.Add(new ObjectBase() { Name = Emp.tenquoctich_BC, Sl = Emp.SL });
            }

        }

        private readonly ObservableCollection<View_DuanDautuByQuoctichHPT> _duandautu_byQuocTichDetail_BC = new ObservableCollection<View_DuanDautuByQuoctichHPT>();
        public ObservableCollection<View_DuanDautuByQuoctichHPT> duandautu_byQuocTichDetail_BC
        {
            get
            {
                return _duandautu_byQuocTichDetail_BC;
            }
        }

        public async void add_duandautubyQuocTichDetail_BC()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byTenQuocTich_BC_HPTAsync();
            _duandautu_byQuocTichDetail_BC.Clear();

            foreach (var Emp in EmpList)
            {
                _duandautu_byQuocTichDetail_BC.Add(new View_DuanDautuByQuoctichHPT() { Id = Emp.Id, Tenquoctich_BC = Emp.tenquoctich_BC, SL = Emp.SL });
            }

        }


        private readonly ObservableCollection<ObjectBase> _duandautu_byQuocTich_BC_USD = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> duandautu_byQuocTich_BC_USD
        {
            get
            {
                return _duandautu_byQuocTich_BC_USD;
            }
        }

        public async void add_duandautubyQuocTich_BC_USD()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byTenQuocTich_BC_USD_HPTAsync();
            _duandautu_byQuocTich_BC_USD.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                if (count > 10) break;
                _duandautu_byQuocTich_BC_USD.Add(new ObjectBase() { Name = Emp.tenquoctich_BC, Sl = (int)Emp.SL });
            }

        }


        private readonly ObservableCollection<ObjectBase> _duandautu_byQuocTichDetail_BC_USD = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> duandautu_byQuocTichDetail_BC_USD
        {
            get
            {
                return _duandautu_byQuocTichDetail_BC_USD;
            }
        }

        public async void add_duandautubyQuocTichDetail_BC_USD()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_byTenQuocTich_BC_USD_HPTAsync();
            _duandautu_byQuocTichDetail_BC_USD.Clear();
       
            foreach (var Emp in EmpList)
            {
                _duandautu_byQuocTichDetail_BC_USD.Add(new ObjectBase() { Name = Emp.tenquoctich_BC, Sl = (int)Emp.SL });
            }

        }

        private readonly ObservableCollection<ObjectBase> _duandautu_top5_USD = new ObservableCollection<ObjectBase>();
        public ObservableCollection<ObjectBase> Duandautu_top5_USD
        {
            get
            {
                return _duandautu_top5_USD;
            }
        }

        public async void add_duandautu_top5_USD()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_top5DAdautu_HPTAsync();
            _duandautu_top5_USD.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                if (count > 5) break;
                _duandautu_top5_USD.Add(new ObjectBase() { Name = Emp.TenDuanDauTu, Sl = (int)Emp.TongvonUSD });
            }

        }


        private readonly ObservableCollection<View_DuanDaututop5HPT> _duandautu_detail_USD = new ObservableCollection<View_DuanDaututop5HPT>();
        public ObservableCollection<View_DuanDaututop5HPT> Duandautu_detail_USD
        {
            get
            {
                return _duandautu_detail_USD;
            }
        }

        public async void add_duandautu_detail_USD()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getViewDADT_top5DAdautu_HPTAsync();
            _duandautu_detail_USD.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                _duandautu_detail_USD.Add(new View_DuanDaututop5HPT() { Sobnhan = count.ToString(), Tenduandautu = Emp.TenDuanDauTu, TongvonUSD = Emp.TongvonUSD });
            }

        }




        #endregion


        #region get chi tiet data dang giai quyet

        private readonly ObservableCollection<View_HSTrackingHPT> _View_HSTrackingHPT = new ObservableCollection<View_HSTrackingHPT>();
        public ObservableCollection<View_HSTrackingHPT> View_HSTrackingHPT
        {
            get
            {
                return _View_HSTrackingHPT;
            }
        }

        public async void add_View_HSTrackingHPT()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getView_HSDangGiaiQuyet_HPTAsync();
            _View_HSTrackingHPT.Clear();

            foreach (var Emp in EmpList)
            {
                _View_HSTrackingHPT.Add(new View_HSTrackingHPT() { Trangthai_hs = Emp.trangthai_hs, Xuly = Emp.xuly, Sl = Emp.SL });
            }

        }

        private readonly ObservableCollection<View_HSTrackingDetailHPT> _HSTrackingDetailHPT = new ObservableCollection<View_HSTrackingDetailHPT>();
        public ObservableCollection<View_HSTrackingDetailHPT> HSTrackingDetailHPT
        {
            get
            {
                return _HSTrackingDetailHPT;
            }
        }
        public async void add_View_HSTrackingDetailHPT(string filter)
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getView_HSDangGiaiQuyetDetail_HPTAsync(filter);
            _HSTrackingDetailHPT.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                _HSTrackingDetailHPT.Add(new View_HSTrackingDetailHPT() { Id = count, Sobnhan = Emp.sobnhan,Tendn = Emp.tendn, Tenda = Emp.tenda, Ngaynhan= Emp.ngaynhan,Ngaytra=Emp.ngaytra,Trangthai_hs = Emp.trangthai_hs, Xuly = Emp.xuly });
            }

        }

        private readonly ObservableCollection<View_HSTrackingDetailHPT> _HSDetailFilter_HPT = new ObservableCollection<View_HSTrackingDetailHPT>();
        public ObservableCollection<View_HSTrackingDetailHPT> HSDetailFilter_HPT
        {
            get
            {
                return _HSDetailFilter_HPT;
            }
        }
        public async void add_View_HSDetailFilter_HPT(int loai_hs, int IsTrinhUB, int IsDungHan)
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getView_ThongTinHSDetail_HPTAsync(loai_hs, IsTrinhUB, IsDungHan);
            _HSDetailFilter_HPT.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                _HSDetailFilter_HPT.Add(new View_HSTrackingDetailHPT() { Id = count, Sobnhan = Emp.sobnhan, Tendn = Emp.tendn, Tenda = Emp.tenda, Ngaynhan = Emp.ngaynhan, Ngaytra = Emp.ngaytra, Trangthai_hs = Emp.trangthai_hs, Xuly = Emp.xuly });
            }

        }


        private readonly ObservableCollection<View_HSTrackingDetailOneHSHPT> _HSTrackingDetailOneHSHPT = new ObservableCollection<View_HSTrackingDetailOneHSHPT>();
        public ObservableCollection<View_HSTrackingDetailOneHSHPT> HSTrackingDetailOneHSHPT
        {
            get
            {
                return _HSTrackingDetailOneHSHPT;
            }
        }
        public async void add_View_HSTrackingDetailOneHSHPT(string filter)
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            var EmpList = await CitydashboardService.getView_DangGiaiQuyetDetailOneHS_HPTAsync(filter);
            _HSTrackingDetailOneHSHPT.Clear();
            int count = 0;
            foreach (var Emp in EmpList)
            {
                count++;
                _HSTrackingDetailOneHSHPT.Add(new View_HSTrackingDetailOneHSHPT() {Trangthai_hs = Emp.TrangthaiXuly, NgayXuly = Emp.Ngayxuly, TenNhanVien= Emp.Tennhanvien });
            }

        }


        #endregion

        public void GetData()
        {

            CitydashboardService = new CitydashboardServiceReference.Service1Client();
            // get ho so nhan
            this.SoHoso = (int)CitydashboardService.GetTongHosoNhanAsync().Result;
            // get ho so dung han / tre han
            this.SohsGQdunghan = (int)CitydashboardService.GetGQDungHanAsync().Result;
            this.SohsGQtrehan = (int)CitydashboardService.GetGQTreHanAsync().Result;
            this.SohsChuaGQdunghan = (int)CitydashboardService.GetChuaGQTrongHanAsync().Result;
            this.SohsChuaGQtrehan = (int)CitydashboardService.GetChuaGQQuaHanAsync().Result;
            this.SohsGQ = this.SohsGQdunghan + this.SohsGQtrehan;
            this.SohsChuaGQ = this.SohsChuaGQdunghan + this.SohsChuaGQtrehan;

            this.dagq_phantram = (float) Math.Round((((float)this.SohsGQ / (float)this.SoHoso) * 100), 2);
            this.chuagq_phantram = (float) Math.Round((((float)this.SohsChuaGQ / (float)this.SoHoso) * 100), 2);

            // phan se bo 
            // get phan tram
            this.per_gqdh = Math.Round((((float)this.SohsGQdunghan / (float)this.SohsGQ) * 100), 2).ToString() + "%";
            this.per_gqth = Math.Round((((float)this.SohsGQtrehan / (float)this.SohsGQ) * 100), 2).ToString() + "%";
            this.per_cgqdh = Math.Round((((float)this.SohsChuaGQdunghan / (float)this.SohsChuaGQ) * 100), 2).ToString() + "%";
            this.per_cgqth = Math.Round((((float)this.SohsChuaGQtrehan / (float)this.SohsChuaGQ) * 100), 2).ToString() + "%";

            //get trinh UBND
            this.TrinhUBND = (int)CitydashboardService.GetHStrinhUBNDAsync().Result;
            this.HSChuaTrinhUBND = (int)CitydashboardService.GetHSChuatrinhUBNDAsync().Result;
            this.TrinhUBND_gq = (int)CitydashboardService.GetHStrinhUBND_dagiaiquyetAsync().Result;
            this.TrinhUBND_cgq = (int)CitydashboardService.GetHStrinhUBND_chuagiaiquyetAsync().Result;
            this.TrinhKHDT = (int)CitydashboardService.GetHStrinhKHDTAsync().Result;
            this.TrinhKHDT_gq = (int)CitydashboardService.GetHStrinhKHDT_dagiaiquyetAsync().Result;
            this.TrinhKHDT_cgq = (int)CitydashboardService.GetHStrinhKHDT_chuagiaiquyetAsync().Result;

            this.hosoTrinhUBDangGQTre ="("+ ((int)CitydashboardService.GetHStrinhUBND_DangGQtreAsync().Result).ToString() + " Trễ)";
            this.hosoTrinhUB_Tre = "("+ ((int)CitydashboardService.GetHStrinhUBND_treAsync().Result).ToString() + " Trễ)";
            this.hosoChuaTrinhUB_Tre = "("+((int)CitydashboardService.GetHSChuatrinhUBND_treAsync().Result).ToString() + " Trễ)"; 

            this.trinhUBdagq_phantram = (float) Math.Round((((float)this.TrinhUBND_gq / (float)this.TrinhUBND) * 100), 2);
            this.trinhUBchuagq_phantram = (float)Math.Round((((float)this.TrinhUBND_cgq / (float)this.TrinhUBND) * 100), 2);
            this.TrinhUB_phantram = (float)Math.Round((((float)this.TrinhUBND / (float)this.SoHoso) * 100), 2);
            this.ChuatrinhUB_phantram = (float) Math.Round((((float)this.HSChuaTrinhUBND / (float)this.SoHoso) * 100), 2);
            // get data du an dau tu
            this.tongduan_dautu = (int)CitydashboardService.GetTongDADTthangAsync().Result;
            this.duanHieuluc = ((int)CitydashboardService.GetDuanHieuLucAsync().Result).ToString() + " DA - " + (Math.Round((float)CitydashboardService.GetDuanHieuLuc_usdAsync().Result,2)).ToString() + " tỉ USD";
            this.doanhnghiepHoatDong = ((int)CitydashboardService.DoanhNghiepHoatDongAsync().Result).ToString() + " DN - " + (Math.Round((float)CitydashboardService.DoanhNghiepHoatDong_usdAsync().Result,2)).ToString() + " tỉ USD";
            this.duanCapmoi = ((int)CitydashboardService.GetDuanCapmoiAsync().Result).ToString() + " DA - " + (Math.Round((float)CitydashboardService.GetDuanCapmoi_usdAsync().Result, 2)).ToString() + " triệu USD";
            this.duanGiaithe = ((int)CitydashboardService.GetDuanGiaiTheAsync().Result).ToString() + " DN - " + (Math.Round((float)CitydashboardService.GetDuanGiaithe_usdAsync().Result, 2)).ToString() + " triệu USD";

            this.tongduanByDN = ((int)CitydashboardService.GettongDuanbyDNAsync().Result).ToString() + " DN";
            this.tongduanByDT = ((int)CitydashboardService.GettongDuanbyDTAsync().Result).ToString() + " DN";
            this.tongduanByDN_usd = (Math.Round((float)CitydashboardService.GettongDuanbyDN_usdAsync().Result, 2)).ToString() + " tỉ USD";
            this.tongduanByDT_usd = (Math.Round((float)CitydashboardService.GettongDuanbyDT_usdAsync().Result, 2)).ToString() + " tỉ USD";
            this.tongduanByDN_int = (int)CitydashboardService.GettongDuanbyDNAsync().Result;
            this.tongduanByDT_int = (int)CitydashboardService.GettongDuanbyDTAsync().Result;

            this.tonghepza = ((int)CitydashboardService.GetHepzaAsync().Result).ToString() + " DA \n" + (Math.Round((float)CitydashboardService.GetHepza_usdAsync().Result, 2)).ToString() + " triệu USD";
            this.tongSHTP = ((int)CitydashboardService.GetSHTPAsync().Result).ToString() + " DA \n" + (Math.Round((float)CitydashboardService.GetSHTP_usdAsync().Result, 2)).ToString() + " triệu USD";
            this.tongOthers = ((int)CitydashboardService.GetothersAsync().Result).ToString() + " DA \n" + (Math.Round((float)CitydashboardService.Getothers_usdAsync().Result, 2)).ToString() + " triệu USD";

        }

       


        #region add data
        public void GetDataduandautu()
        {
           
            add_duandautubyloaiDN();
            add_duandautubyloaihinhDT();
            add_duandautubyloaihinhDT_USD();
            add_duandautubyQuocTich_BC();
            add_duandautubyQuocTich_BC_USD();
            add_duandautubyQuocTichDetail_BC();
            add_duandautu_top5_USD();
            add_duandautu_detail_USD();
            add_duandautubyQuocTichDetail_BC_USD();
        }


        public void GetDataTracking()
        {
            add_View_HSTrackingHPT();
        }

        public void RefreshData()
        {
            add_ViewTTTongQuatHPT();
            add_TrinhUB_gqdh();
            add_TrinhUB_gqth();
            add_TrinhUB_cgqdh();
            add_TrinhUB_cgqth();
            add_View_HSTrackingHPT();

            add_HsDaGiaiQuyet();
            add_HsDangGiaiQuyet();
            GetDataduandautu();

            GetData();
        }
        #endregion
        #endregion

        public MainViewModel()
        {
            RefreshData();
        }
    }
}
